package thread;

public class DaemonThreadTest {

	public static void main(String[] args) {
		
		Thread t = new Thread(){

			@Override
			public void run() {
				
				try {
					Thread.sleep(3000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("子线程执行完毕");
			}
			
		};
		t.setDaemon(true); //设置为后台进程后，主线程执行完毕，子线程也立即终止
		t.start();
		
		System.out.println("主线程执行完毕");
	}
}
